import { SkillCareerPanel } from "./SkillCareerPanel";
import { Cache } from "../../../cache/Cache";
import { ObjCreate } from "../../common/ObjCreate";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { Language } from "../../../../../extend/language/Language";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { TweenMax } from "../../../../../com/greensock/TweenMax";
import { SkillCareerMapGradePanel } from "./SkillCareerMapGradePanel";
import { SkillCareerInfoGradePanel } from "./SkillCareerInfoGradePanel";
import { GButton } from "../../../../../com/mui/controls/GButton";
//class SkillCareerGradePanel
    
    export  class SkillCareerGradePanel extends SkillCareerPanel
    {
        constructor()
        {
            super();
            return;
        }

        /* internal  */updateActive(): void
        {
            var loc1=null;
            var loc2=null;
            if (Cache.instance.skill.actived() && (!this._outTween || this._outTween.active == false)) 
            {
                if (this._activeMask && this._activeMask.parent) 
                {
                    this.removeChild(this._activeMask);
                }
            }
            else 
            {
                _skillList.alpha = 0.8;
                _skillInfo.alpha = 0.8;
                if (!this._activeMask) 
                {
                    this._activeMask = new Object /* flash.display.Sprite */();
                    ObjCreate.createBg(0, 0, width, height, this._activeMask);
                    loc1 = new GTextFormat(FontUtil.lishuName, 24, 14030555);
                    loc1.leading = 6;
                    loc1.letterSpacing = 4;
                    loc1.align = flash.text.TextFormatAlign.CENTER;
                    this._activeTxt = ObjCreate.createTextField("", 0, 50, width, height, this._activeMask, loc1);
                    this._activeTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
                    this._activeTxt.multiline = true;
                    this._activeTxt.wordWrap = true;
                    this._activeTxt.width = width;
                    loc2 = Language.getString(27530);
                    this._activeTxt.htmlText = HTMLUtil.addColor(loc2, "#D616DB");
                    this._activeBtn = ObjCreate.createGButton(Language.getString(27529), 0, 0, 74, 24, this._activeMask, "ButtonRed");
                    this._activeBtn.x = (width - this._activeBtn.width) / 2;
                    this._activeBtn.y = height - 50;
                    this._activeBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onActiveBtnClickHandler);
                }
                this._activeMask.alpha = 1;
                this.addChild(this._activeMask);
            }
            return;
        }

        /* internal  */onActiveBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.SkillActiveReq));
            this.hideMask();
            return;
        }

        /* internal  */hideMask(): void
        {
            _skillList.alpha = 0;
            _skillInfo.alpha = 0;
            this._outTween = TweenMax.to(this._activeMask, 0.5, {"alpha": 0, "onComplete": this.onHideMask});
            TweenMax.to(_skillList, 0.5, {"alpha": 1});
            TweenMax.to(_skillInfo, 0.5, {"alpha": 1});
            return;
        }

        /* internal  */onHideMask(): void
        {
            if (this._activeMask && this._activeMask.parent) 
            {
                this.removeChild(this._activeMask);
            }
            return;
        }

        public /* override */ initSkill(arg1: Array<any>, arg2: Boolean=true): void
        {
            super.initSkill(arg1, arg2);
            if (arg2) 
            {
                this.updateActive();
            }
            return;
        }

        protected /* override */ creatChirldren(): void
        {
            super.creatChirldren();
            _skillList = new SkillCareerMapGradePanel();
            _skillList.addEventListener(flash.events.MouseEvent.CLICK, onSkillMapClickHandler);
            addChild(_skillList);
            _skillInfo = new SkillCareerInfoGradePanel();
            addChild(_skillInfo);
            return;
        }

        protected /* override */ updateSize(): void
        {
            _skillList.x = 0;
            _skillList.y = 0;
            _skillInfo.x = 256;
            _skillInfo.y = 0;
            return;
        }

        /* internal */ /* var */_activeBtn: GButton;

        /* internal */ /* var */_activeTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_activeMask: Object /* flash.display.Sprite */;

        /* internal */ /* var */_outTween: TweenMax;
    }
